#pragma once

#include <iostream>
#include <string>
#include <algorithm>

#include "../comm/log.hpp"
#include "../comm/util.hpp"
#include "oj_model.hpp"

namespace ns_control
{
    using namespace std;
    using namespace ns_model;
    using namespace ns_util;
    using namespace ns_log;

    class Control
    {
    private: 
    Model model_;
    public:
    bool AllQuestions(string*html)//输出型，参数
    {
        bool ret=true;
        vector<Question> all;
        if(model_.GetAllQuestions(&all))
        {
            sort(all.begin(),all.end(),[](const struct Question&q1,const struct Question&q2)
            {
                return atoi(q1.number.c_str())<atoi(q2.number.c_str());
            });
        }
        else
        {
            *html="获取题目失败，形成题目列表失败";
            ret=false;
        }
        return ret;
        //获得题目的信息，构建网页
    }

    bool Question(const string&number,string*html)
    {
        bool ret=true;
        struct Question q;
        if(model_.GetOneQuestions(&q))
        {
            
        }
        else
        {
            *html="指定题目："+number+" 不存在！";
            ret =false;
        }
        return ret;
    }


    };
};